<?php

class App_Mailer extends Zend_Mail
{
	
	protected static $_defaultView;
	
	protected $_view;
	
	protected static function getDefaultView(){
		if(self::$_defaultView == null){
			self::$_defaultView = new Zend_View();
			self::$_defaultView->setScriptPath(APPLICATION_PATH . '/views/emails');
		}
		
		return self::$_defaultView;
	}
	
	public function __construct($charset = 'utf-8'){
		parent::__construct();
		
		$this->_view = self::getDefaultView();
	}
	
	public function setViewParam($param,$value){
		$this->_view->$param = $value;
		
		return $this;
	}
	
	public function sendHtmlTemplate($template,$encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE){
		$html = $this->_view->render($template);
		$this->setBodyHtml($html, $this->getCharset(), $encoding);
		$this->send();
	}
	
}